// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Belt Activation Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 58 : TYPE_BELTACTIVATION


// Static Values

// Tables

event ObjectMain
	arrayPos0 = object.value1
	while arrayPos0 < object.value0
		object[arrayPos0].priority = PRIORITY_ACTIVE
		arrayPos0++
	loop
end event


event ObjectDraw
	arrayPos0 = object.value1
	while arrayPos0 < object.value0
		if stage.state == STAGE_RUNNING
			object[arrayPos0].priority = PRIORITY_INACTIVE
		else
			object[arrayPos0].priority = PRIORITY_ACTIVE
		end if
		arrayPos0++
	loop
end event


event ObjectStartup
	foreach (TypeName[Belt Activation], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].priority = PRIORITY_XBOUNDS
		arrayPos1 = arrayPos0
		object[arrayPos0].value0 = object[arrayPos0].propertyValue
		temp0 = 0
		while temp0 == 0
			if object[arrayPos1].type == TypeName[Belt Platform]
				object[arrayPos0].value1 = arrayPos1
				temp0 = 1
			else
				arrayPos1++
				if arrayPos1 >= 0x420
					temp0 = 1
				end if
			end if
		loop
		object[arrayPos0].value0 += object[arrayPos0].value1
	next
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
